#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ll n,l,r;
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld %lld %lld",&n,&l,&r);
	ll k = min(n-1-(l%n)+l, r);
	printf("%lld",k%n);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
